<!--- Based on sphinx versionwarning extension. Extension currently only works on READTHEDOCS -->
  <script>
    startsWith = function(str, needle) {
      return str.slice(0, needle.length) == needle
    }
    // Create a banner if we're not on the official docs site
    if (location.host == "docs.testing.ansible.com") {
      document.write('<div id="testing_banner_id" class="admonition important">');
      document.write('<p>This is the testing site for Ansible Documentation. Unless you are reviewing pre-production changes, please visit the <a href="https://docs.ansible.com/ansible/latest/">official documentation website</a>.</p> <p></p>');
      document.write('</div>');
    }
    {% if (not READTHEDOCS) and (available_versions is defined) %}
      // Create a banner if we're not the latest version
      current_url_path = window.location.pathname;
      if (startsWith(current_url_path, "/ansible/latest/") || startsWith(current_url_path, "/ansible/{{ latest_version }}/")) {
       // no banner for latest release
       // temp banner to advertise AnsibleFest
        document.write('<div id="banner_id" class="admonition important">');
        document.write('<p><a href="https://www.ansible.com/ansiblefest">AnsibleFest</a> is going virtual with two days of expert speakers, live demos and hands-on labs Oct 13-14!</p>');
        document.write('</div>');

      } else if (startsWith(current_url_path, "/ansible/devel/")) {
        document.write('<div id="banner_id" class="admonition caution">');
        document.write('<p>You are reading the *devel* version of the Ansible documentation - this version is not guaranteed stable. Use the version selection to the left if you want the latest stable released version.</p>');
        document.write('</div>');
      } else {
        document.write('<div id="banner_id" class="admonition caution">');
        document.write('<p>You are reading an older version of the Ansible documentation. Use the version selection to the left if you want the latest stable released version.</p>');
        document.write('</div>');
      }
    {% endif %}
  </script>
